#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int countPrimes(int n)
    {
        std::vector<int> isPrime(n, 1);
        int count = 0;
        for (int i = 2; i < n; ++i)
        {
            if (isPrime[i] == 1)
            {
                ++count;
                for (int j = i; (long long)j * i < n; ++j)
                {
                    isPrime[j * i] = 0;
                }
            }
        }
        return count;
    }
};